#include "Reactor.h"
#include "Socket.h"
#include "CallBack.h"

int main()
{
    Reactor* R = new Reactor();
    R->Init();

    int listen_sock = Socket::SocketCreate();
    SetNonBlock(listen_sock);
    Socket::SocketBind(listen_sock,8080);
    Socket::SocketListen(listen_sock,5);

    EventItem item;
    item.sock_ = listen_sock;
    item.R_ = R;
    item.RegisterCallBacks(Accepter,nullptr,nullptr);

    R->AddEvent(listen_sock,EPOLLIN|EPOLLET,item);
    int timeout = 1000;
    while(true)
        R->Dispatcher(timeout);
    return 0;
}